class_name BuffReaperDeath
extends BaseBuff

@onready var view_root: Node2D = $ViewRoot
@onready var animation_player: AnimationPlayer = $ViewRoot/AnimationPlayer
@export var distance_2_holder: float = 32
@export var cam_shake_intensity: float = 2.0
@export var cam_shake_duration: float = 0.2


func _ready() -> void:
	start_buff()


func start_buff():
	holder.states.transition("Empty")
	holder.disable_hurt_collision()
	holder.disable_body_collision()
	holder.pause_animation()
	holder.velocity = Vector2.ZERO
	
	var holder_face = holder.get_face()
	position.x = - holder_face * distance_2_holder
	view_root.scale.x = holder_face
	
	animation_player.play("reaper_death")
	
	await animation_player.animation_finished
	queue_free()
	

func set_death():
	var hit_data = HitData.new()
	
	hit_data.is_critical = true
	hit_data.knockback = 0
	hit_data.direct_dead = true
	
	holder.take_hit(hit_data)
	holder.level.camera.start_shake(cam_shake_intensity, cam_shake_duration)
